package cn.demoncat.util.mysql.entity;

import java.util.ArrayList;
import java.util.List;

/**
 * 描述：代码生成-实体类
 *
 * @author yxl
 *
 * @version 2.0
 *
 * @since 2016年7月9日
 */
public class DbGenEntity {
	
	// 作者
	private String author;
	// 版本
	private String version;
	// 包名
	private String packageName;
	// 类名
	private String name;
	// 类简名（首字母小写的类名）
	private String simpleName;
	// 类全名
	private String fullName;
	// 类注释
	private String comment;
	// 注释时间
	private String time;
	// URL前缀
	private String url;
	// Base包名
	private String basePackage;
	// Base类型：DbGenConstant.BaseType
	private String baseType;
	// 属性
	private List<DbGenAttr> attrs = new ArrayList<>();
	// id属性
	private DbGenAttr idAttr;
	// sort属性
	private boolean hasSort;
	// name属性
	private boolean hasName;
	// title属性
	private boolean hasTitle;

	public DbGenEntity() {
		// 初始化ID字段：默认没有ID会报错，宽松场景用默认值来防止异常
		idAttr = new DbGenAttr();
		idAttr.setType("String");
	}

	public String getPackageName() {
		return packageName;
	}

	public void setPackageName(String packageName) {
		this.packageName = packageName;
	}

	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		this.time = time;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getVersion() {
		return version;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	public String getBasePackage() {
		return basePackage;
	}

	public void setBasePackage(String basePackage) {
		this.basePackage = basePackage;
	}

	public String getBaseType() {
		return baseType;
	}

	public void setBaseType(String baseType) {
		this.baseType = baseType;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSimpleName() {
		return simpleName;
	}

	public void setSimpleName(String simpleName) {
		this.simpleName = simpleName;
	}

	public String getFullName() {
		return fullName;
	}

	public void setFullName(String fullName) {
		this.fullName = fullName;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}
	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}
	public List<DbGenAttr> getAttrs() {
		return attrs;
	}

	/**
	 * 设置属性
	 * @param attrs
	 */
	public void setAttrs(List<DbGenAttr> attrs) {
		// 所有属性
		this.attrs = attrs;
		for (DbGenAttr attr : attrs) {
			switch (attr.getName()) {
				case "id":
					// id属性
					this.idAttr = attr;
					break;
				case "sort":
					// sort属性
					this.hasSort = true;
					break;
				case "name":
					// name属性
					this.hasName = true;
					break;
				case "title":
					// title属性
					this.hasTitle = true;
					break;
			}
		}
	}

	public DbGenAttr getIdAttr() {
		return idAttr;
	}

	public void setIdAttr(DbGenAttr idAttr) {
		this.idAttr = idAttr;
	}

	public boolean isHasSort() {
		return hasSort;
	}

	public void setHasSort(boolean hasSort) {
		this.hasSort = hasSort;
	}

	public boolean isHasName() {
		return hasName;
	}

	public void setHasName(boolean hasName) {
		this.hasName = hasName;
	}

	public boolean isHasTitle() {
		return hasTitle;
	}

	public void setHasTitle(boolean hasTitle) {
		this.hasTitle = hasTitle;
	}
}
